<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        window.onload=function () {
            var btnEle = document.querySelector('#btn');
           /* btnEle.onclick=function () {
                console.log(1);
            }
            btnEle.onclick=function () {
                console.log(2);
            }*/
        btnEle.addEventListener('click',function () {
            console.log(1);
        })
            var listener=function () {
                console.log(2);
            }
            btnEle.addEventListener('click',listener)
        }

    </script>
</head>
<body>
<button onclick="sendMessage()">发送短信</button>
<button id="btn">按钮</button>
</body>
</html>